package ZY11_23;

import java.net.InetAddress;

public class Test2MyServer {
    public static void main(String[] args) {
        try {
            InetAddress ipv4 = InetAddress.getLocalHost();
            String nativeip = ipv4.getHostAddress();
            System.out.println("本机名：" + ipv4.getHostName());
            System.out.println("本机IP:" + nativeip);

            String url = "www.baidu.com";
            InetAddress ip = null;
            ip = InetAddress.getByName(url);
            System.out.println("域名" + url + "对应的IP地址是：" + ip.getHostAddress());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
